<template>
    <view class="content">
        <view class="box" v-for="(item, index) in list" :key="index">
            <view class="item">
                <view class="left">日期</view>
                <view class="right">{{item.date}}</view>
            </view>
            <view class="item">
                <view class="left">订单编号</view>
                <view class="right">{{item.out_trade_no}}</view>
            </view>
            <view class="item">
                <view class="left">线路</view>
                <view class="right">{{item.line}}</view>
            </view>
            <view class="item">
                <view class="left">反馈内容</view>
                <view class="right">{{item.feedback}}</view>
            </view>
            <view class="item">
                <view class="left">联系人</view>
                <view class="right">{{item.name}}</view>
            </view>
            <view class="item">
                <view class="left">联系方式</view>
                <view class="right">{{item.phone}}</view>
            </view>
            <view class="item" v-if="item.images && item.images.length > 0">
                <view class="left">图片</view>
                <view class="right">
                    <image :src="el" class="img" v-for="(el, ind) in item.images" :key="ind" @click="$previewImage(item.images, ind)"></image>
                </view>
            </view>
            <view class="item" v-if="item.examine_tim">
                <view class="left">反馈日期</view>
                <view class="right">{{item.examine_time}}</view>
            </view>
            <view class="item" v-if="item.suggestions">
                <view class="left">反馈结果</view>
                <view class="right">{{item.suggestions}}</view>
            </view>
        </view>
		
		<view style="height: 94rpx;padding-top: 30rpx;">
		    <u-loadmore :status="status" v-if="status != 'loadmore'" />
		</view>
        
        <view class="footer" @click="$gTo(`/pages/feedback/create`)">添加记录</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
            };
        },
		onLoad() {
			// 接收添加意见反馈记录 监听
			uni.$on('FEEDBACK', data => {
				this.list = []
				this.page = 1
				this.status = 'loadmore'
				this.getList()
			})
			
			this.getList()
		},
		onReachBottom() {
			if(this.page == 1){return}
			this.getList()
		},
        methods: {
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('select_feedback', {
            		user_token: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
            	}).then(ret => {
            		if (ret.success == 1000) {
            			if (ret.detail && ret.detail.feedback && ret.detail.feedback.length > 0) {
            				this.list = this.list.concat(ret.detail.feedback);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #eef1f6;
    }
    .content{
        padding: 20rpx 20rpx 100rpx;
    }
    .box{
        padding: 40rpx 20rpx 30rpx;
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 16rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding-bottom: 10rpx;
    }
    .left{
        width: 140rpx;
        color: #656565;
    }
    .right{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .img{
        width: 187rpx;
        height: 187rpx;
        margin-right: 10rpx;
        margin-bottom: 10rpx;
    }
    
    .footer{
        width: 100%;
        height: 95rpx;
        background-color: #00457f;
        font-size: 34rpx;
        color: #fff;
        text-align: center;
        line-height: 95rpx;
        position: fixed;
        left: 0;
        bottom: 0;
    }
    
    

</style>
